package t20220305;

import java.io.PrintStream;
import java.util.Formatter;

/**
 * @Author: DengJia
 * @Date: 2022/3/5 14:05
 * @Description:
 */

public class Turtle {
    private String name;
    private Formatter formatter;

    public Turtle(String name, Formatter formatter) {
        this.name = name;
        this.formatter = formatter;
    }

    public void move(int x, int y) {
        formatter.format("%s The Turtle is at (%d, %d)\n", name, x, y);
    }

    public static void main(String[] args) {
        PrintStream out = System.err;
        Turtle tommy = new Turtle("Tommy", new Formatter(System.out));
        Turtle jerry = new Turtle("Jerry", new Formatter(out));

        tommy.move(0, 0);
        jerry.move(1, 1);
        tommy.move(2, 2);
        jerry.move(3, 3);
        tommy.move(4, 4);
        jerry.move(5, 5);
    }
}
